<script setup>
	import {
		getCurrentInstance
	} from "vue"
	import {
		onLaunch,
		onShow,
		onHide
	} from '@dcloudio/uni-app'
	const {
		proxy
	} = getCurrentInstance()
	const mp = uni.requireNativePlugin('uniMP')
	onLaunch(() => {
		uni.removeStorageSync("appSystemInfo")
		uni.getSystemInfo({
			success: function(res) {
				uni.setStorageSync("appSystemInfo", res)
			}
		})

		proxy.$helper.goHome()

		//监听小程序通讯数据
		mp.onUniMPEventReceive(ret => {
			//监听小程序token状态
			if (ret.event == "invalid_token") {
				uni.removeStorageSync("token")
				proxy.$helper.goHome()
			}
			//监听小程序授权登录
			if (ret.event == "user_login" && uni.getStorageSync('token')) {
				//传参只能是Object
				mp.sendUniMPEvent(ret.fromAppid, 'auth_token', {
					'phone': uni.getStorageSync('token'),
					'name': 'token'
				})
			}

		});
	})
	onShow(() => {
		console.log('BaseApp Show')
	})
	onHide(() => {
		console.log('BaseApp Hide')
	})
</script>

<style>
	/*每个页面公共css */
</style>